package com.qf.service.impl;

import com.qf.entity.Student;
import com.qf.mapper.StudentMapper;
import com.qf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Lenovo
 * @version 1.0
 * @date 2021/10/4
 */
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> findAllStudent() {
        return  studentMapper.findAllStudent();
    }

    @Override
    @Transactional
    public void insertStudent(Student student) {
        int i = studentMapper.insert(student);
        if (i!=1){
            System.out.println("插入学生失败");
            throw new RuntimeException("插入学生失败");
        }
    }
}
